<template>
    <div>
      <div>全国省份价格发布数量分布</div>
      <div>
        <div>请选择类型：</div>
        <el-radio-group v-model="typeClass" class="ml-4" >
          <el-radio v-for="item in typeEnum" :label=item :key=item size="large">{{ item }}</el-radio>
        </el-radio-group>
      </div>
      <div>
        <ElButton @click=submit type="primary">提交</ElButton>
      </div>
      <div>
        <Map v-if="showPigPricePublishCnt" :data="pigPricePublishCnt"></Map>
      </div>
    </div>

</template>

<script setup>
import Map from "./map.vue";
import {ref} from "vue";
import {getPublishNumber} from "../services/data.js";
import {pigPricePublishCntOptions} from "../data/options.js";

let showPigPricePublishCnt = ref(false)
const pigPricePublishCnt = ref([])
const typeClass = ref('')
const typeEnum = ['内三元', '外三元', '土杂猪']


const getPublicNumberFn = async () => {
  try {
    // const res = await getPublishNumber()
    // const res = await import("../data/t1.json")
    pigPricePublishCnt.value=[]
    const res = await getPublishNumber({category: typeClass.value})
    res.data.forEach(item => {
      const obj = {
        id: item[0],
        name: item[1],
        value: item[2]
      }
      pigPricePublishCnt.value.push(obj)
    })
    pigPricePublishCntOptions.value.series[0].data = pigPricePublishCnt.value
    console.log(pigPricePublishCntOptions.value)

    showPigPricePublishCnt.value = true
  } catch (err) {
    console.log(err)
  }
}

const submit=()=>{
  getPublicNumberFn()
}
</script>

<style scoped>

</style>